package com.qfedu.mtl.service.impl;

import com.qfedu.mtl.dao.BrandDao;
import com.qfedu.mtl.dao.impl.BrandDaoImpl;
import com.qfedu.mtl.entity.Brand;
import com.qfedu.mtl.query.BrandQuery;
import com.qfedu.mtl.service.BrandService;
import com.qfedu.mtl.util.page.Pager;

import java.util.List;

public class BrandServiceImpl implements BrandService {

    //引入持久层组件(对象)
    private BrandDao brandDao = new BrandDaoImpl();

    @Override
    public Pager<Brand> findPage(Integer page, Integer size, BrandQuery query) {
        List<Brand> list = brandDao.selectData(page, size, query);
        Integer total = brandDao.selectTotal(query);
        Pager<Brand> pager = new Pager<>(list, page, size,total);
        return pager;
    }

    @Override
    public Brand findById(Integer id) {
        return brandDao.selectById(id);
    }

    @Override
    public void save(Brand brand) {
            brandDao.insert(brand);
    }

    @Override
    public void update(Brand brand) {
           brandDao.update(brand);
    }

    @Override
    public void delete(Integer id) {
         brandDao.delete(id);
    }

    @Override
    public void deleteBatch(List<Integer> ids) {
           brandDao.deleteBatch(ids);
    }
}
